<template>
  <div v-loading="loading">
    <queryHead v-if="head" :explain="explain" :result="msg" :time="time" :price="price" @query="query"/>
    <div v-if="lock" style="background-color: #fafafa;padding: 5px;border-radius: 5px">

      <table id="fxbg">
        <tr class="fxbg_border_none">
          <td colspan="60"><h2>天启探知报告</h2></td>
        </tr>
        <tr class="fxbg_border_none">
          <td colspan="60">
            <div style="display: flex;justify-content: space-around;">
              <div style="width: 40vw"><p style="float:left ;margin: 0px">报告生成时间：{{ time }}</p></div>
              <div style="width: 40vw">
                <p v-show="show" style="text-align: right;margin: 0px;color: red" @click="downLoadPDF()">
                  下载报告
                </p>
              </div>
            </div>
            <hr style="border:1px solid black;color: #0d99fd"/>
          </td>

        </tr>
        <tr class="fxbg_border_none">
          <td colspan="12" rowspan="3"/>
          <td colspan="6" rowspan="3">
            <img style="margin-right: 30px"
                 src=""/>
          </td>
          <td colspan="2" rowspan="3"/>
          <td colspan="14" style="font-size: 20px">{{ setYc(info.name) }}</td>
          <td colspan="14">性别：{{ getSex(info.cardNo) }}</td>
          <td colspan="12" rowspan="3"/>
        </tr>

        <tr class="fxbg_border_none">
          <td colspan="14">手机号：{{ setYc(info.tel) }}</td>
          <td colspan="14">出生日期：{{ getBirth(info.cardNo) }}</td>
        </tr>
        <tr class="fxbg_border_none">
          <td colspan="14">身份证号：{{ setYc(info.cardNo) }}</td>
          <td colspan="14">年龄：{{ getAge(info.cardNo) }}</td>
        </tr>

        <tr class="fxbg_border_none">
          <td colspan="60" style="text-align: left">
            <h2>风险建议：{{ qwd.jy }}</h2>
          </td>
        </tr>

        <tr class="fxbg_border_none">
          <td colspan="54" style="text-align: left;">
            <el-tag v-bind:style="{marginLeft: qwd.fs+'%'}" effect="dark">
              {{ numDelivery(260 * (1 - qwd.fs / 100) + 390) }}
            </el-tag>
          </td>
          <td colspan="6"></td>
        </tr>
        <tr class="fxbg_border_none">
          <td colspan="12" style="background-color: #73d13d; width: 20%">极低风险</td>
          <td colspan="12" style="background-color: #37cec9; width: 20%">低风险</td>
          <td colspan="12" style="background-color: #43a9fd; width: 20%">中风险</td>
          <td colspan="12" style="background-color: #feab43; width: 20%">高风险</td>
          <td colspan="12" style="background-color: #fa4147; width: 20%">极高风险</td>
        </tr>
        <tr class="fxbg_border_none">
          <td colspan="6" style="text-align: left;">650</td>
          <td colspan="12">590</td>
          <td colspan="12">530</td>
          <td colspan="12">470</td>
          <td colspan="12">410</td>
          <td colspan="6" style="text-align: right">0</td>
        </tr>
        <tr class="fxbg_border_none">
          <td colspan="60" style="text-align: left">
            <i class="el-icon-s-check">
              <label>风险标注：</label>
            </i>
          </td>
        </tr>
        <tr class="fxbg_titles">
          <td colspan="30">
            风险点
          </td>
          <td colspan="30">
            详解
          </td>
        </tr>
        <tr v-for="(objValue) of qwd.hit_rules.ruleexecutionlimited">
          <td colspan="30">
            {{ objValue.name_rule }}
          </td>
          <td colspan="30">
            置信度:{{ objValue.weight }}%，详解见下方
          </td>
        </tr>

        <tr v-for="(objValue) of qwd.hit_rules.rulespeciallist_c">
          <td colspan="30">
            {{ objValue.name_rule }}
          </td>
          <td colspan="30">
            置信度:{{ objValue.weight }}%，详解见下方
          </td>
        </tr>

        <tr v-for="(objValue) of qwd.hit_rules.ruleapplyloan">
          <td colspan="30">
            {{ objValue.name_rule }}
          </td>
          <td colspan="30">
            置信度:{{ objValue.weight }}%，详解见下方
          </td>
        </tr>

        <tr class="fxbg_border_none">
          <td colspan="60" style="text-align: left">
            <i class="el-icon-s-check">
              <label>关联风险：</label>
            </i>
          </td>
        </tr>
        <tr>
          <td colspan="30">
            同一身份证关联手机号数
          </td>
          <td colspan="30">
            {{ 'ident_contain_phone_ct' in qwd.zlxw ? qwd.zlxw.ident_contain_phone_ct : '未命中' }}
          </td>
        </tr>

        <tr>
          <td colspan="30">
            同一手机号关联身份证数
          </td>
          <td colspan="30">
            {{ 'phone_contain_ident_ct' in qwd.zlxw ? qwd.zlxw.tel_contain_ident_ct : '未命中' }}
          </td>
        </tr>

        <tr class="fxbg_border_none">
          <td colspan="60" style="text-align: left">
            <i class="el-icon-s-check">
              <label>身份信息核验：</label>
            </i>
          </td>
        </tr>
        <tr class="fxbg_titles">
          <td colspan="10">实名认证</td>
          <td colspan="40">运营商手机三要素</td>
          <td colspan="10">在网时长(月)</td>
        </tr>
        <tr>
          <td colspan="10" rowspan="3">姓名与身份证号
            <label>
              {{ qwd.jbxx.smrz.final_valid_result == '0' ? '一致' : '不一致' }}
            </label></td>
          <td colspan="10">服务商</td>
          <td colspan="10">服务商代码</td>
          <td colspan="10">归属省份</td>
          <td colspan="10">归属城市</td>
          <td colspan="10" rowspan="3">
            <label>
              {{ qwd.jbxx.sjzwsj.time }}
            </label>
          </td>
        </tr>
        <tr>
          <td colspan="10">{{ qwd.jbxx.sjsys.attribute }}</td>
          <td colspan="10">{{ qwd.jbxx.sjsys.attribute_en }}</td>
          <td colspan="10">{{ qwd.jbxx.sjsys.province }}</td>
          <td colspan="10">{{ qwd.jbxx.sjsys.city }}</td>
        </tr>
        <tr>
          <td colspan="40">
            <label>
              {{
                qwd.jbxx.sjsys.checkResult == '0' ? '手机号与身份证号，姓名一致' : qwd.jbxx.sjsys.checkResult == '1' ? '手机号与身份证号或姓名不一致' : ''
              }}
            </label>
          </td>
        </tr>

        <tr class="fxbg_border_none">
          <td colspan="60" style="text-align: left">
            <i class="el-icon-s-check">
              <label>不良行为核验：</label>
            </i>
          </td>
        </tr>
        <tr class="fxbg_titles">
          <td colspan="8">前科</td>
          <td colspan="8">涉毒</td>
          <td colspan="8">吸毒</td>
          <td colspan="8">其它</td>
          <td colspan="7">经济类前科</td>
          <td colspan="12">侵犯公民人身，民主权利</td>
          <td colspan="9">扰乱公共秩序罪</td>
        </tr>
        <tr>
          <td colspan="8">
            {{ qwd.blxw == 'A' || qwd.blxw == 'J' || qwd.blxw == 'N' || qwd.blxw == 'R' ? '有命中' : '良好无记录' }}
          </td>
          <td colspan="8">{{ qwd.blxw == 'B' ? '有命中' : '良好无记录' }}</td>
          <td colspan="8">{{ qwd.blxw == 'C' ? '有命中' : '良好无记录' }}</td>
          <td colspan="8">{{ qwd.blxw == 'F' ? '有命中' : '良好无记录' }}</td>
          <td colspan="7">{{ qwd.blxw == 'J' ? '有命中' : '良好无记录' }}</td>
          <td colspan="12">{{ qwd.blxw == 'N' ? '有命中' : '良好无记录' }}</td>
          <td colspan="9">{{ qwd.blxw == 'R' ? '有命中' : '良好无记录' }}</td>
        </tr>

        <tr class="fxbg_border_none">
          <td colspan="60" style="text-align: left">
            <i class="el-icon-s-check">
              <label>风险名单：</label>
            </i>
          </td>
        </tr>
        <tr class="fxbg_titles" style="background-color: #73d13d">
          <td colspan="12">
            涉案
          </td>
          <td colspan="12">
            破产清算
          </td>
          <td colspan="12">
            法院失信人
          </td>
          <td colspan="12">
            法院被执行
          </td>
          <td colspan="12">
            银行(含信用卡)
          </td>
        </tr>
        <tr>
          <td colspan="12" v-for="(item,index) of qwd.fxmd" v-if="index<5">
            {{ item }}
          </td>
        </tr>
        <tr class="fxbg_titles" style="background-color: #73d13d">
          <td colspan="12">
            持牌汽车金融
          </td>
          <td colspan="12">
            持牌消费金融
          </td>
          <td colspan="12">
            持牌融资租赁
          </td>
          <td colspan="12">
            持牌小贷
          </td>
          <td colspan="12">
            其它风险
          </td>
        </tr>
        <tr>
          <td colspan="12" v-for="(item,index) of qwd.fxmd" v-if="index>4">
            {{ item }}
          </td>
        </tr>

        <tr class="fxbg_border_none">
          <td colspan="60" style="text-align: left">
            <i class="el-icon-s-check">
              <label>历史借贷行为：</label>
            </i>
          </td>
        </tr>
        <tr>
          <td colspan="30">
            <div id="sqjgs" style="width: 40vw;height:400px;"></div>
          </td>
          <td colspan="30">
            <div id="sqcs" style="width: 40vw;height:400px;"></div>
          </td>
        </tr>
        <tr>
          <td colspan="20">
            申请机构总数：{{ sumSq(qwd.lsjdxw.sqjg) }}
          </td>
          <td colspan="20">
            申请总次数：{{ sumSq(qwd.lsjdxw.sqcs) }}
          </td>
          <td colspan="20">
            距离最近一次申请已有天数：{{ qwd.lsjdxw.jlts }}
          </td>
        </tr>

        <tr class="fxbg_border_none">
          <td colspan="60" style="text-align: left">
            <i class="el-icon-s-check">
              <label>近24个月放贷情况：</label>
            </i>
          </td>
        </tr>
        <tr class="fxbg_titles">
          <td colspan="12">放款机构总数</td>
          <td colspan="12">消金类放贷机构数</td>
          <td colspan="12">网贷类放贷机构数</td>
          <td colspan="12">最近一次放款日期</td>
          <td colspan="12">最近一次放款日期已有天数</td>
        </tr>
        <tr>
          <td colspan="12" v-for="(item,index) of qwd.fdqk">
            {{ item }}
          </td>
        </tr>
        <tr class="fxbg_border_none">
          <td colspan="60"></td>
        </tr>
        <tr class="fxbg_titles">
          <td colspan="10"></td>
          <td colspan="10">近1个月</td>
          <td colspan="10">近3个月</td>
          <td colspan="10">近6个月</td>
          <td colspan="10">近12个月</td>
          <td colspan="10">近24个月</td>
        </tr>
        <tr v-for="(item,index) in qwd.fdqk1_24">
          <td v-if="index == 0" colspan="10">放款次数</td>
          <td v-else colspan="10">放款金额</td>
          <td v-for="(item_) in item" colspan="10">{{ item_ }}</td>
        </tr>

        <tr class="fxbg_border_none">
          <td colspan="60" style="text-align: left">
            <i class="el-icon-s-check">
              <label>履约情况：</label>
            </i>
          </td>
        </tr>
        <tr class="fxbg_titles">
          <td colspan="15" v-for="(item) in qjldParams.qwdlyqk">{{ item.ct }}</td>
        </tr>
        <tr>
          <td colspan="15" v-for="(item) in qwd.lyqk"> {{ item }}</td>
        </tr>
        <tr class="fxbg_border_none">
          <td class="fxbg_border_none" colspan="60"></td>
        </tr>
        <tr class="fxbg_titles">
          <td colspan="10"></td>
          <td colspan="10">近1个月</td>
          <td colspan="10">近3个月</td>
          <td colspan="10">近6个月</td>
          <td colspan="10">近12个月</td>
          <td colspan="10">近24个月</td>
        </tr>
        <tr v-for="(item,index) in qwd.lyqk1_24">
          <td v-if="index == 0" colspan="10">履约次数</td>
          <td v-else-if="index == 1" colspan="10">履约金额</td>
          <td v-else colspan="10">还款异常次数</td>
          <td v-for="(item_) in item" colspan="10">{{ item_ }}
          </td>
        </tr>

        <tr class="fxbg_border_none">
          <td colspan="60" style="text-align: left">
            <i class="el-icon-s-check">
              <label>历史逾期记录：</label>
            </i>
          </td>
        </tr>
        <tr class="fxbg_titles">
          <td colspan="15">当前逾期机构数（家）</td>
          <td colspan="15">当前逾期金额（元）</td>
          <td colspan="15">当前是否存在逾期未结清</td>
          <td colspan="15">历史贷款机构交易失败笔数</td>
        </tr>
        <tr>
          <td colspan="15">
            {{
              qwd.lsyqjl[0] == '1' ? '[1,2)' : qwd.lsyqjl[0] == '2' ? '[2,4)' : qwd.lsyqjl[0] == '3' ? '[4, Inf)' : qwd.lsyqjl[0]
            }}
          </td>
          <td colspan="15">
            {{
              qwd.lsyqjl[1] == '1' ? '(0,1000)' : qwd.lsyqjl[1] == '2' ? '[1000,2000)' : qwd.lsyqjl[1] == '3' ? '[2000,3000)' :
                qwd.lsyqjl[1] == '4' ? '[3000,5000)' : qwd.lsyqjl[1] == '5' ? '[5000,7000)' : qwd.lsyqjl[1] == '6' ? '[7000,11000)' :
                  qwd.lsyqjl[1] == '7' ? '[11000,Inf)' : qwd.lsyqjl[1]
            }}
          </td>
          <td colspan="15">
            {{ qwd.lsyqjl[2] == '1' ? '逾期' : qwd.lsyqjl[2] == '0' ? '未逾期' : '' }}
          </td>
          <td colspan="15">
            {{
              qwd.lsyqjl[3] == '1' ? '0-3笔' : qwd.lsyqjl[3] == '2' ? '3-5笔' : qwd.lsyqjl[3] == '3' ? '5-10笔' : qwd.lsyqjl[3] == '4' ? '10笔及以上' : qwd.lsyqjl[3]
            }}
          </td>
        </tr>
        <tr class="fxbg_border_none">
          <td colspan="60"></td>
        </tr>
        <tr class="fxbg_titles">
          <td colspan="15">最近1天是否发生过逾期</td>
          <td colspan="15">最近7天是否发生过逾期</td>
          <td colspan="15">最近14天是否发生过逾期</td>
          <td colspan="15">最近30天是否发生过逾期</td>
        </tr>
        <tr>
          <td colspan="15">
            {{ qwd.lsyqjl[4] == '1' ? '逾期' : qwd.lsyqjl[4] == '0' ? '未逾期' : '' }}
          </td>
          <td colspan="15">
            {{ qwd.lsyqjl[5] == '1' ? '逾期' : qwd.lsyqjl[5] == '0' ? '未逾期' : '' }}
          </td>
          <td colspan="15">
            {{ qwd.lsyqjl[6] == '1' ? '逾期' : qwd.lsyqjl[6] == '0' ? '未逾期' : '' }}
          </td>
          <td colspan="15">
            {{ qwd.lsyqjl[7] == '1' ? '逾期' : qwd.lsyqjl[7] == '0' ? '未逾期' : '' }}
          </td>
        </tr>

        <tr class="fxbg_border_none">
          <td colspan="60"></td>
        </tr>
        <tr class="fxbg_titles">
          <td colspan="15"></td>
          <td colspan="15">近6个月</td>
          <td colspan="15">近12个月</td>
          <td colspan="15">近24个月</td>
        </tr>
        <tr v-for="(item,index) in qwd.lsyqjl1_24">
          <td v-if="index == 0" colspan="15">M0+笔数</td>
          <td v-else-if="index == 1" colspan="15">M1+笔数</td>
          <td v-else colspan="15">累计金额</td>
          <td v-for="(item_) in item" colspan="15">{{ item_ }}
          </td>
        </tr>

        <tr class="fxbg_border_none">
          <td colspan="60" style="text-align: left">
            <i class="el-icon-s-check">
              <label>授信详情：</label>
            </i>
          </td>
        </tr>
        <tr class="fxbg_titles">
          <td colspan="10"></td>
          <td colspan="25">网络贷款类</td>
          <td colspan="25">分期消费类</td>
        </tr>
        <tr>
          <td colspan="10">最大授信额度</td>
          <td colspan="25">{{ qwd.sxxq[0] }}
          </td>
          <td colspan="25">{{ qwd.sxxq[1] }}
          </td>
        </tr>
        <tr>
          <td colspan="10">平均授信额度</td>
          <td colspan="25">{{ qwd.sxxq[2] }}
          </td>
          <td colspan="25">{{ qwd.sxxq[3] }}
          </td>
        </tr>

        <tr class="fxbg_border_none">
          <td colspan="60" style="text-align: left">
            <i class="el-icon-s-check">
              <label>租赁申请行为：</label>
            </i>
          </td>
        </tr>
        <tr class="fxbg_titles">
          <td colspan="10">申请\时间</td>
          <td colspan="10">近 7 天</td>
          <td colspan="10">近 1 个月</td>
          <td colspan="10">近 3 个月</td>
          <td colspan="10">近 6 个月</td>
          <td colspan="10">近 12 个月</td>
        </tr>
        <tr>
          <td colspan="10">申请平台数</td>
          <td colspan="10">{{
              'd7_apply_agency_time' in qwd.zlxw ? qwd.zlxw.d7_apply_agency_time : ''
            }}
          </td>
          <td colspan="10">{{
              'm1_apply_agency_time' in qwd.zlxw ? qwd.zlxw.m1_apply_agency_time : ''
            }}
          </td>
          <td colspan="10">{{
              'm3_apply_agency_time' in qwd.zlxw ? qwd.zlxw.m3_apply_agency_time : ''
            }}
          </td>
          <td colspan="10">{{
              'm6_apply_agency_time' in qwd.zlxw ? qwd.zlxw.m6_apply_agency_time : ''
            }}
          </td>
          <td colspan="10">
            {{ 'm12_apply_agency_time' in qwd.zlxw ? qwd.zlxw.m12_apply_agency_time : '' }}
          </td>
        </tr>
        <tr>
          <td colspan="10">申请次数</td>
          <td colspan="10">{{ 'd7_apply_time' in qwd.zlxw ? qwd.zlxw.d7_apply_time : '' }}</td>
          <td colspan="10">{{ 'm1_apply_time' in qwd.zlxw ? qwd.zlxw.m1_apply_time : '' }}</td>
          <td colspan="10">{{ 'm3_apply_time' in qwd.zlxw ? qwd.zlxw.m3_apply_time : '' }}</td>
          <td colspan="10">{{ 'm6_apply_time' in qwd.zlxw ? qwd.zlxw.m6_apply_time : '' }}</td>
          <td colspan="10">{{ 'm12_apply_time' in qwd.zlxw ? qwd.zlxw.m12_apply_time : '' }}</td>
        </tr>
        <tr>
          <td colspan="10">在夜间申请平台数</td>
          <td colspan="10">{{
              'd7_night_apply_agency_time' in qwd.zlxw ? qwd.zlxw.d7_night_apply_agency_time : ''
            }}
          </td>
          <td colspan="10">{{
              'm1_night_apply_agency_time' in qwd.zlxw ? qwd.zlxw.m1_night_apply_agency_time : ''
            }}
          </td>
          <td colspan="10">{{
              'm3_night_apply_agency_time' in qwd.zlxw ? qwd.zlxw.m3_night_apply_agency_time : ''
            }}
          </td>
          <td colspan="10">{{
              'm6_night_apply_agency_time' in qwd.zlxw ? qwd.zlxw.m6_night_apply_agency_time : ''
            }}
          </td>
          <td colspan="10">{{
              'm12_night_apply_agency_time' in qwd.zlxw ? qwd.zlxw.m12_night_apply_agency_time : ''
            }}
          </td>
        </tr>
        <tr>
          <td colspan="10">在夜间申请次数</td>
          <td colspan="10">{{ 'd7_night_apply_time' in qwd.zlxw ? qwd.zlxw.d7_night_apply_time : '' }}</td>
          <td colspan="10">{{ 'm1_night_apply_time' in qwd.zlxw ? qwd.zlxw.m1_night_apply_time : '' }}</td>
          <td colspan="10">{{ 'm3_night_apply_time' in qwd.zlxw ? qwd.zlxw.m3_night_apply_time : '' }}</td>
          <td colspan="10">{{ 'm6_night_apply_time' in qwd.zlxw ? qwd.zlxw.m6_night_apply_time : '' }}</td>
          <td colspan="10">{{
              'm12_night_apply_time' in qwd.zlxw ? qwd.zlxw.m12_night_apply_time : ''
            }}
          </td>
        </tr>

        <tr class="fxbg_border_none">
          <td colspan="60" style="text-align: left">
            <i class="el-icon-s-check">
              <label>法院涉案风险信息：</label>
            </i>
          </td>
        </tr>
        <tr class="fxbg_titles">
          <td colspan="11">案号</td>
          <td colspan="6">案件类型</td>
          <td colspan="9">法院</td>
          <td colspan="4">诉讼身份</td>
          <td colspan="6">立案时间</td>
          <td colspan="6">案件状态</td>
          <td colspan="6">案由</td>
          <td colspan="6">结案方式</td>
          <td colspan="6">涉案总额</td>

        </tr>
        <template v-for="(objValue,key,index) of qwd.fyxx" v-if="includesf(key,objValue)">
          <!--                    {{ objValue }}-->
          <tr v-for="(cases,i) in objValue.cases">

            <td colspan="11">{{ cases.c_ah }}</td>
            <td colspan="6">{{ include(key) }}</td>
            <td colspan="9">{{ cases.n_jbfy }}</td>
            <td colspan="4">{{ cases.n_ssdw }}</td>

            <td colspan="6">{{ cases.d_larq }}</td>

            <td colspan="6">{{ cases.n_ajlx }}</td>
            <td colspan="6">{{ cases.n_laay }}</td>
            <td colspan="6">{{ cases.n_jafs }}</td>
            <td colspan="6">{{ cases.n_sqzxbdje }}</td>
          </tr>
        </template>
        <tr v-if="qwd.fyxx.length == 0 || !isXr">
          <td colspan="60">
            未命中到数据
          </td>
        </tr>
        <!--                  <tr class="fxbg_border_none">-->
        <!--                    <td colspan="60">-->
        <!--                      微信扫一扫，快速一键查询！-->
        <!--                    </td>-->
        <!--                  </tr>-->
        <!--                  <tr class="fxbg_border_none">-->
        <!--                    <td colspan="60">-->
        <!--                      <img-->
        <!--                        src="@/assets/images/4_聚法分析报告.jpg"-->
        <!--                        style="width: 16%"-->
        <!--                        alt="donate"/>-->
        <!--                    </td>-->
        <!--                  </tr>-->

      </table>
    </div>
    <h3 v-if="sjsysMsg" style="text-align: center">{{ sjsysMsg }}</h3>
    <h3 v-if="jxzsMsg" style="text-align: center">{{ jxzsMsg }}</h3>
  </div>
</template>

<script>
  import queryHead from "@/views/components/queryHead.vue";
  import * as echarts from 'echarts';
  import {
    disposeFxmd,
    disposeLsjdxw,
    tranStr,
    getDeepData
  } from '@/utils/neatenData.js';
  import {queryRecord, queryData, reportFee} from "@/api/system/query";
  import {qjldParams} from '@/utils/qjldParams.js';
  import {downloadPDF} from "@/utils/htmlToPdf.js";

  export default {
    components: {queryHead},
    name: "qwdbg",
    props: {
      queryData: {
        required: true,
        type: Object
      },
      price: {
        default: null,
        type: Number
      },
      priceType: {
        default: null,
        type: Boolean
      },
      explain: {
        default: null,
        type: String
      },
      info: {
        required: true,
        type: Object
      },
      head: {
        default: true,
        type: Boolean
      }
    },
    data() {
      return {
        qjldParams,
        loading: false,
        show: true,
        lock: false,

        msg: undefined,
        time: undefined,

        isXr: undefined,

        blxwMsg: null,
        dqMsg: null,
        jxzsMsg: null,
        sfMsg: null,
        sjsysMsg: null,
        smrzMsg: null,
        zulinMsg: null,
        zwscMsg: null,

        jbxx: {
          smrz: {
            final_valid_result: ''
          },
          sjsys: {
            attribute: '',
            attribute_en: '',
            checkResult: '',
            city: '',
            province: ''
          },
          sjzwsj: {
            time: ''
          }
        },

        qwd: {
          jy: '暂无',
          fs: 70,

          hit_rules: {
            ruleexecutionlimited: {},
            rulespeciallist_c: {},
            ruleapplyloan: {},
          },
          jbxx: {},	//原
          blxw: '',	//原

          fxmd: ['未命中', '未命中', '未命中', '未命中', '未命中', '未命中', '未命中', '未命中', '未命中', '未命中'],

          lsjdxw: {
            sqjg: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            sqcs: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            jlts: ''
          },
          fdqk: ['暂无数据', '暂无数据', '暂无数据', '暂无数据', '暂无数据'],
          fdqk1_24: [['暂无数据', '暂无数据', '暂无数据', '暂无数据', '暂无数据'], ['暂无数据', '暂无数据', '暂无数据', '暂无数据', '暂无数据']],
          lyqk: ['暂无数据', '暂无数据', '暂无数据', '暂无数据'],
          lyqk1_24: [['暂无数据', '暂无数据', '暂无数据', '暂无数据', '暂无数据'], ['暂无数据', '暂无数据', '暂无数据', '暂无数据', '暂无数据'], ['暂无数据', '暂无数据', '暂无数据', '暂无数据', '暂无数据']],
          lsyqjl: ['暂无数据', '暂无数据', '暂无数据', '暂无数据', '暂无数据', '暂无数据', '暂无数据', '暂无数据'],
          lsyqjl1_24: [['暂无数据', '暂无数据', '暂无数据'], ['暂无数据', '暂无数据', '暂无数据'], ['暂无数据', '暂无数据', '暂无数据']],
          sxxq: ['暂无数据', '暂无数据', '暂无数据', '暂无数据'],
          zlxw: {
            d7_apply_time: "未命中",
            m6_apply_time: "未命中",
            m6_night_apply_agency_time: "未命中",
            m3_apply_agency_time: "未命中",
            m12_apply_agency_time: "未命中",
            m1_apply_time: "未命中",
            ident_last_apply_time: "未命中",
            d7_night_apply_agency_time: "未命中",
            m12_apply_time: "未命中",
            m3_night_apply_time: "未命中",
            m1_apply_agency_time: "未命中",
            m12_night_apply_agency_time: "未命中",
            d7_night_apply_time: "未命中",
            m1_night_apply_agency_time: "未命中",
            phone_contain_ident_ct: "未命中",
            m6_night_apply_time: "未命中",
            ident_contain_phone_ct: "未命中",
            m1_night_apply_time: "未命中",
            m12_night_apply_time: "未命中",
            m3_apply_time: "未命中",
            d7_apply_agency_time: "未命中",
            m6_apply_agency_time: "未命中",
            m3_night_apply_agency_time: "未命中"
          },
          fyxx: {}
        }
      }
    },
    created() {
      this.loading = true
      queryRecord(this.queryData).then(response => {
        this.disResponse(response)
      })
    },
    methods: {
      query() {
        this.loading = true;
        queryData(this.queryData).then(response => {
          this.disResponse(response)
        });
      },

      disResponse(response) {
        if (response.time) {
          this.time = response.time;
        }
        if (!response.info) {
          this.loading = false;
          return
        }
        let result = JSON.parse(response.info);
        // console.log('---result---', result);
        try {
          let sjsysRes = result.sjsys
          if (sjsysRes.retcode == '000000') {
            this.jbxx.sjsys = sjsysRes.retdata
          } else {
            this.$modal.msgWarning('手机三要素查询失败，原因：' + sjsysRes.retmsg);
            this.sjsysMsg = sjsysRes.retmsg
          }

          let smrzRes = result.smrz
          if (smrzRes.retcode == '000000') {
            this.jbxx.smrz.final_valid_result = smrzRes.retdata.final_valid_result
          } else {
            this.$modal.msgWarning('实名认证查询失败，原因：' + smrzRes.retmsg)
            this.smrzMsg = smrzRes.retmsg
          }

          const retcode = result.zwsc.retcode
          if (retcode == '000000' || retcode == '000001' || retcode == '000002' || retcode == '000003' || retcode == '100000') {
            const inTime = result.zwsc.retdata.inTime
            this.jbxx.sjzwsj.time = '0' == inTime ? '[0,3)' : '3' == inTime ? '[3,6) ' : '6' == inTime ? '[6,12)' : '12' == inTime ? '[12,24)' : '24' == inTime ? '[24,+) ' : '99' == inTime ? '手机号已离网/新入网/手机状态异常' : '-1' == inTime ? '查无记录' : inTime
          } else {
            this.$modal.msgWarning('在网时长查询失败，原因：' + result.zwsc.retmsg)
          }
          this.qwd.jbxx = this.jbxx

          // 不良行为
          console.log('--不良行为--', result.blxw)
          if (result.blxw.retcode == '000000') {
            this.qwd.blxw = result.blxw.retdata.level
          }
          let pf = []

          // 全景雷达
          let qjld = result.qjld
          console.log('--全景雷达--', qjld)
          if (qjld) {
            qjld = qjld.retdata
            // 申请准入分
            const sqzrf = getDeepData(qjld, ['apply_report_detail', 'A22160001'])
            if (sqzrf != '未命中') {
              pf.push(tranStr(sqzrf) / 10)
            }
            // 放贷情况
            this.qwd.fdqk = [
              getDeepData(qjld, ['behavior_report_detail', 'B22170020']),
              getDeepData(qjld, ['current_report_detail', 'C22180007']),
              getDeepData(qjld, ['current_report_detail', 'C22180003']),
              getDeepData(qjld, ['behavior_report_detail', 'B22170054']),
              getDeepData(qjld, ['behavior_report_detail', 'B22170050'])]
            // 放贷情况近24个月
            qjldParams.qwdfdqk1_24.forEach((value, index) => {
              value.forEach((item, index_) => {
                this.qwd.fdqk1_24[index][index_] = getDeepData(qjld, ['behavior_report_detail', item])
              })
            })
            // 履约情况
            qjldParams.qwdlyqk.forEach((value, index) => {
              this.qwd.lyqk[index] = getDeepData(qjld, ['behavior_report_detail', value.et])
            })
            // 履约情况近24个月
            qjldParams.qwdlyqk1_24.forEach((value, index) => {
              value.forEach((item, index_) => {
                this.qwd.lyqk1_24[index][index_] = getDeepData(qjld, ['behavior_report_detail', item])
              })
            })
            // 历史逾期记录近24个月
            qjldParams.qwdlsyqjl1_24.forEach((value, index) => {
              value.forEach((item, index_) => {
                this.qwd.lsyqjl1_24[index][index_] = getDeepData(qjld, ['behavior_report_detail', item])
              })
            })
            // 授信详情
            qjldParams.qwdsxxq.forEach((value, index) => {
              this.qwd.sxxq[index] = getDeepData(qjld, ['current_report_detail', value])
            })
          }

          // 借选指数
          console.log('--借选指数--', result.jxzs)
          if (result.jxzs.retcode == '000000' || result.jxzs.retcode == '100000') {
            // 借选指数_获取整合评分
            let retdata = result.jxzs.retdata
            // pf.push('1   ' + tranStr(retdata.xyp_cpl0081) * 100)
            // pf.push('1   ' + tranStr(retdata.xyp_cpl0082) * 100)
            // pf.push('1   ' + tranStr(retdata.xyp_cpl0083) * 100)
            // if (retdata.xyp_model_score_high != -1) {
            //   pf.push(Math.floor((tranStr(retdata.xyp_model_score_high) / 9) * 100) / 100)
            // }
            // if (retdata.xyp_model_score_mid != -1) {
            //   pf.push(Math.floor((tranStr(retdata.xyp_model_score_mid) / 9) * 100) / 100)
            // }
            // if (retdata.xyp_model_score_low != -1) {
            //   pf.push(Math.floor((tranStr(retdata.xyp_model_score_low) / 9) * 100) / 100)
            // }
            // 历史逾期记录
            qjldParams.qwdlsyqjl.forEach((value, index) => {
              this.qwd.lsyqjl[index] = getDeepData(retdata, [value])
            })
          } else {
            this.jxzsMsg = result.jxzs.retmsg
          }

          console.log('--租赁--', result.zulin)
          if (result.zulin.retcode == '000000') {
            const retdata = result.zulin.retdata
            if (retdata.resultCode == 1) {
              // 租赁行为
              this.qwd.zlxw = retdata.detail
            }
            // const fw = getDeepData(retdata, ['Rule', 'result', 'final_weight'])
            // if (fw != '未命中') {
            //   pf.push(tranStr(fw))
            // }
          }

          console.log('--司法--', result.sf)
          if (result.sf.retcode == '000000') {
            const retdata = result.sf.retdata

            if (retdata.resultCode == 1) {
              // 法院风险信息
              const detail0 = retdata.detail[0]
              this.qwd.fyxx = detail0
              // 涉案总数
              const sact = getDeepData(detail0, ['count', 'count_total'])
              this.qwd.fxmd[0] = sact == '未命中' ? sact : '命中（' + sact + '）'
              // 破产清算
              const pcct = getDeepData(detail0, ['bankrupt', 'count', 'count_total'])
              this.qwd.fxmd[1] = pcct == '未命中' ? pcct : '命中（' + pcct + '）'
            }
            // const fw = getDeepData(retdata, ['Rule', 'result', 'final_weight'])
            // if (fw != '未命中') {
            //   pf.push(tranStr(fw))
            // }
          }

          console.log('---多头---', result.dq)
          if (result.dq.retcode == '000000') {
            const retdata = result.dq.retdata
            if (retdata.Flag.specialList_c == '1') {
              let slc = disposeFxmd(retdata.SpecialList_c)
              slc.forEach((value, index) => {
                // 风险名单
                this.qwd.fxmd[index + 2] = slc[index]
              })
            }

            console.log('---retdata.Flag.applyloanstr---', retdata.Flag.applyloanstr)
            if (retdata.Flag.applyloanstr == '1') {
              // 历史借贷行为

              this.qwd.lsjdxw = disposeLsjdxw(retdata.ApplyLoanStr)
            }
            // 风险标注
            let hit_rules = this.qwd.hit_rules
            this.qwd.hit_rules = {
              ...hit_rules,
              ...retdata.Rule.hit_rules
            }
            const fw = getDeepData(retdata, ['Rule', 'result', 'final_weight'])
            if (fw != '未命中') {
              pf.push(tranStr(fw))
            }
          }


          // 整理评分
          let sumPf = 0
          console.log('---整理评分---: ', pf)
          pf.forEach(function (item) {
            sumPf += (item / pf.length)
          })
          this.qwd.fs = this.numDelivery(sumPf == 0 ? 20 : sumPf)
          this.qwd.jy = this.qwd.fs < 40 ? '通过' : this.qwd.fs >= 70 ? '拒绝' : '复议'
          this.msg = "查询完成"
          this.xrsj()
          this.lock = true
          this.loading = false
        } catch (err) {
          console.error(err)
          this.loading = false;
        }
      },

      xrsj() {
        // 渲染图
        setTimeout(() => {  // 异步任务（宏任务）
          let titles = ['银行', '非银行', '信用卡', '线下消费分期', '线下现金分期', '线上小额现金贷', '线上消费分期', '线上现金分期', '汽车金融', '其它']
          let sqjgsTitles = [], sqcsTitles = []
          for (let i = 0; i < titles.length; i++) {
            sqjgsTitles.push({
              value: this.qwd.lsjdxw.sqjg[i] ? this.qwd.lsjdxw.sqjg[i] : 0, name: titles[i]
            })
            sqcsTitles.push({
              value: this.qwd.lsjdxw.sqcs[i] ? this.qwd.lsjdxw.sqcs[i] : 0, name: titles[i]
            })
          }
          // 绘制图表
          echarts.init(document.getElementById('sqjgs')).setOption({
            title: {
              text: '申请机构数',
              subtext: '身份证与手机号合计申请',
              left: 'center'
            },
            series: [
              {
                name: 'sqjgs',
                type: 'pie',
                label: {
                  show: true,
                  position: 'outside',
                  formatter: '{b}:({c}家)'
                },
                radius: [20, 140],
                roseType: 'area',
                itemStyle: {
                  borderRadius: 5
                },
                data: sqjgsTitles
              }
            ]
          });
          echarts.init(document.getElementById('sqcs')).setOption({
            title: {
              text: '申请次数',
              subtext: '身份证与手机号合计申请',
              left: 'center'
            },
            series: [{
              name: 'sqcs',
              type: 'pie',
              label: {
                show: true,
                position: 'outside',
                formatter: '{b}:({c}次)'
              },
              radius: [20, 140],
              roseType: 'area',
              itemStyle: {
                borderRadius: 5
              },
              data: sqcsTitles
            }]
          });
        }, 800)
      },

      setYc(item) {
        if (!item) {
          return ''
        } else {
          return "**" + item.substring(item.length / 2, item.length)
        }
      },

      getSex(UUserCard) {
        return parseInt(UUserCard.substr(16, 1)) % 2 === 1 ? '男' : '女'
      },

      getBirth(UUserCard) {
        const birth =
          UUserCard.substring(6, 10) + "-" +
          UUserCard.substring(10, 12) + "-" +
          UUserCard.substring(12, 14)
        return birth
      },

      getAge(UUserCard) {
        const myDate = new Date()
        const age = myDate.getFullYear() - UUserCard.substring(6, 10);
        return age
      },

      numDelivery(num) {
        let result = parseFloat(num);
        if (isNaN(result)) {
          return 0
        }
        result = Math.round(num * 100) / 100
        return result
      },

      includesf(item, obj) {
        let ss = false
        if (['civil', 'criminal', 'administrative', 'implement', 'bankrupt', 'preservation'].indexOf(item) != -1 && 'cases' in obj) {
          ss = true
          this.isXr = true
        }
        return ss
      },
      include(item) {
        let index = ['civil', 'criminal', 'administrative', 'implement', 'bankrupt', 'preservation'].indexOf(item)
        return ["民事案件", "刑事案件", "行政案件", "执行案件", "破产清算", "非诉讼保全审查"][index]
      },
      sumSq(items) {
        let sum = 0
        for (let i = 0; i < items.length; i++) {
          sum += items[i]
        }
        return sum
      },
      deepData(data, keys) {
        return getDeepData(data, keys)
      },
      downLoadPDF() {
        this.show = false;
        reportFee({
          productId: 15,
          queryId: this.queryData.queryId,
        }).then(response => {
          if (response.code == 200) {
            downloadPDF(document.getElementById('fxbg'), '天启风险分析报告' + this.setYc(this.info.name) + '.pdf')
          } else {
            this.$modal.msgWarning(response.msg);
          }
          this.show = true;
        });
      }
    }
  };
</script>

<style scoped>
  #fxbg {
    margin: 10px auto;
    width: 98%;
    padding: 0 50px;
    table-layout: fixed;
    border-collapse: collapse;
  }

  #fxbg td {
    border: 1px solid #000000;
    text-align: center;
    width: 1.64%;
    padding: 15px 0px;
  }

  .fxbg_titles {
    background-color: #f3f4f8;
  }

  #fxbg .fxbg_border_none td {
    border: none;
    /*border: 1px solid red;*/
  }
</style>
